﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="Title" runat="server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Harmonic</h2>
    <h2>
        <%: ViewBag.Message %></h2>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">
            http://asp.net/mvc</a>.
    </p>
    <p>
        Here is a selection of our products:
    </p>
    <%Html.BeginForm(); %>
    <table>
        <tr>
            <th>
                Name
            </th>
            <th>
                Price
            </th>
            <%if (Request.IsAuthenticated)
              {%>
            <th>
                Add
            </th>
        </tr>
        <%} %>
        <%foreach (var item in ViewData["AllProducts"] as IEnumerable<Harmonic.ReadModel.Product>)
          {%>
        <tr>
            <td>
                <%: Html.ActionLink(item.ProductName, "Details", "Product", new { item.ProductId }, null)%>
            </td>
            <td>
                <%: item.Price %>
            </td>
            <%if (Request.IsAuthenticated)
              {%>
            <td>
                <%: Html.ActionLink("Add to Cart", "AddToCart", "Product", new { item.ProductId }, null)%>
            </td>
            <%} %>
        </tr>
        <%} %>
    </table>
    <%Html.EndForm(); %>
</asp:Content>
